<!--
 * @Author: Wangtao
 * @Date: 2022-05-05 10:47:22
 * @LastEditors: Wangtao
 * @LastEditTime: 2022-06-14 23:21:57
-->
<template>
  <div>
    <el-form class="m7-form accessForm" :rules="rules"
      size="mini" :model="accessForm"
      ref="accessForm" label-position="top">
      <el-form-item label="企业名称" prop="name">
        <el-input v-model.trim="accessForm.name" size="mini" :disabled="true"></el-input>
      </el-form-item>
      <el-form-item label="会话流程" prop="processId">
        <m7Select filterable
         v-model="accessForm.processId"
         size="mini" :options="processData"
         :defaultProps="{value: '_id', label: 'name'}"
         placeholder="请选择">
        </m7Select>
      </el-form-item>
      <!-- <el-form-item label="满意度评价" prop="isSatisfaction">
        <el-switch
          v-model="accessForm.isSatisfaction"
          active-color="#13ce66"
          inactive-color="#ff4949">
        </el-switch>
      </el-form-item> -->
      <!-- <el-form-item prop="openAssistance">
        <span slot="label">
          启用智能辅助
        </span>
        <el-switch
          v-model="accessForm.isEnableRobotAssist"
          active-color="#13ce66"
          inactive-color="#ff4949">
        </el-switch>
      </el-form-item> -->
    </el-form>
  </div>
</template>
<script lang='ts'>
import { Component, Vue } from 'vue-property-decorator'
import { deepClone } from '@/utils/common'
interface AccessForm {
  name: string
  processId: string
  corpId?: string
  isEnableRobotAssist: boolean // 启用智能辅助
}
const accessFormTem = {
  name: '',
  processId: '',
  isEnableRobotAssist: false
}
@Component({
  name: 'WechatServiceAccessAddOrEdit'
})
export default class WechatServiceAccessAddOrEdit extends Vue {
  private $store: any

  get processData () {
    return this.$store.state.common.publicCache.processList || []
  }

  private rules = {
    processId: [{ required: true, trigger: 'change', message: '请选择会话流程' }]
  }

  public accessForm: AccessForm = deepClone(accessFormTem)

  public setAccessData (data?: any) {
    if (data) {
      const { name, processId, _id, isEnableRobotAssist } = data
      this.accessForm = {
        corpId: _id,
        name,
        processId,
        isEnableRobotAssist
      }
    } else {
      this.accessForm = deepClone(accessFormTem)
    }
  }
}
</script>
<style lang="stylus" scoped>
  .tip-span
    font-size 12px
    color #B3B9C7
    cursor pointer
</style>
